package jdbc;

import javax.swing.plaf.nimbus.State;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

/**
 * 执行修改操作
 */
public class JDBCDemo3 {
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.cj.jdbc.Driver");
        Connection connection= DriverManager.getConnection("jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root",
                "root");
        Statement state=connection.createStatement();

        String sql="UPDATE userinfo\n" +
                "SET password='666666'\n" +
                "WHERE username='张三'";
        int num=state.executeUpdate(sql);
        System.out.println(num>0?"修改成功":"修改失败");
        connection.close();

    }

}
